app.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider
  /*----------------组织机构管理----------------------*/
  .state('organizations', {
    url: '/organizations',
    templateUrl: 'app/partials/organizations/index.html',
    controller: function($scope,Organization,$location, OrganizationCategory, PositionStandardAssignment) {
      $scope.widget_title = '组织机构管理';   
      
      $scope.treeOptions = {
        nodeChildren: "children",
        dirSelectable: true,
        injectClasses: {
            ul: "a1",
            li: "a2",
            liSelected: "a7",
            iExpanded: "a3",
            iCollapsed: "a4",
            iLeaf: "a5",
            label: "a6",
            labelSelected: "a8"
        }
      }
      $scope.dataForTheTree= Organization.get_tree();

      $scope.showSelected = function(selectNode){
        $location.url("/organizations/" + selectNode._id )
      }
   }
  })
  .state('organizations.show', {
    url: '/:id',
    templateUrl: 'app/partials/organizations/show.html',
    controller: function($scope,OrganizationCategory, Position, $state, $stateParams, PositionStandardAssignment, OrganizationCategoryPositionStandard, Organization, RequireCertificateOrgan, OrganizationRank, $location) {

      $scope.require_certificate_organs = RequireCertificateOrgan.query();
      $scope.current_organization = Organization.get({id: $stateParams.id});
      $scope.organization = Organization.get({id: $stateParams.id});
      // $scope.organization_positions = Organization.get_employee_and_positions({id: $stateParams.id})

      $scope.update = function(data){
        Organization.assignment_position_standard({id: $stateParams.id}, data, function(nr){
          $state.transitionTo('organizations.show',$stateParams,{reload: true});
        });
      }
   }
  })
  
})